package com.ibm.cps.kafka;

import java.io.Serializable;

import com.ibm.cps.message.MessageFactory;
import com.ibm.cps.message.MessageFields;

/**
 * Created by gongxuan on 12/2/15.
 */
public class KafkaTopicConstructorForMultiTenants implements KafkaTopicConstructor,Serializable {
    JudgeTenantType judgeTenantType = new JudgeTenantType();
    public String getMessageTopic(String tenantid) {
        if(judgeTenantType.IsNormalTenants(tenantid)){
            return MessageFactory.MessageType.JSON_DATA_MESSAGE.name() + MessageFields.NORMAL_TENANT;
        }
        else{
            return MessageFactory.MessageType.JSON_DATA_MESSAGE.name() + tenantid;

        }
    }

    public String getMessageCountTopic(String tenantid) {
        if(judgeTenantType.IsNormalTenants(tenantid)){
            return MessageFactory.MessageType.MESSAGE_COUNT.name() +MessageFields.NORMAL_TENANT;
        }
        else{
            return MessageFactory.MessageType.MESSAGE_COUNT.name() + tenantid;

        }
    }

    public String getMetadataAddTopic(String tenantid) {
        if(judgeTenantType.IsNormalTenants(tenantid)){
            return MessageFactory.MessageType.PROCESSORS.name() +MessageFields.NORMAL_TENANT;
        }
        else{
            return MessageFactory.MessageType.PROCESSORS.name() + tenantid;

        }
    }

    public String getMetadataDeleteTopic(String tenantid) {
        if(judgeTenantType.IsNormalTenants(tenantid)){
            return MessageFactory.MessageType.DELETE_PROCESSORS.name() +MessageFields.NORMAL_TENANT;
        }
        else{
            return MessageFactory.MessageType.DELETE_PROCESSORS.name() + tenantid;

        }
    }

    public String getDataSourceDeleteTopic(String tenantid) {
        if(judgeTenantType.IsNormalTenants(tenantid)){
            return MessageFactory.MessageType.DELETE_DATA_SOURCE_TOPIC.name() + MessageFields.NORMAL_TENANT;
        }
        else{
            return MessageFactory.MessageType.DELETE_DATA_SOURCE_TOPIC.name() + tenantid;

        }
    }

    public String getDataSourceAddTopic(String tenantid) {
        if(judgeTenantType.IsNormalTenants(tenantid)){
            return MessageFactory.MessageType.ADD_DATA_SOURCE_TOPIC.name() + MessageFields.NORMAL_TENANT;
        }
        else{
            return MessageFactory.MessageType.ADD_DATA_SOURCE_TOPIC.name() + tenantid;

        }
    }
}
